package com.ash.service.impl;

import com.ash.dao.imp.DaoImpl;
import com.ash.dao.imp.UserDaoImpl;
import com.ash.entity.User;
import com.ash.service.IUserService;

import java.util.List;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2020/12/25 15:39
 * @file : test06.com.ash.service.impl.UserServiceImpl.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
public class UserServiceImpl implements IUserService {
    public DaoImpl<User> dao;

    public UserServiceImpl() {
        dao=new DaoImpl<>(User.class,"userCode");
    }

    @Override
    public User login(User user) {
        List<User> select = dao.select(user);
        return select==null||select.size()==0?null:select.get(0);
    }

    @Override
    public int update(User user) {
        return dao.modify(user);
    }

    @Override
    public List<User> selectUser(Integer id, String keyWord) {
        UserDaoImpl userDao = new UserDaoImpl();
        return userDao.getSpecifiedUser(id, keyWord);
    }

    @Override
    public int delete(User user) {
       return  dao.delete(user);
    }

    @Override
    public int add(User user) {
        return dao.add(user);
    }
}
